﻿@{
	List<TBM.Models.MainMenu> MenuList = (List<TBM.Models.MainMenu>)ViewBag.MenuList;
}
@helper TreeNode(List<TBM.Models.MainMenu> nodes){
	if(nodes != null && nodes.Any()){
		<ol class="dd-list">
			@foreach(TBM.Models.MainMenu item in nodes){
			<li class="dd-item dd3-item" data-id="@item.ID">
				<div class="dd-handle dd3-handle">
				</div>
				<div class="dd3-content">
					<div class="clearfix">
						<div class="pull-left">
							<i class="@item.Icon"></i> @item.PageName
						</div>
						<div class="pull-right btn-switch">
							<i class="fa fa-caret-down"></i>
						</div>
					</div>
					<div class="form-body">
						<div class="form-group row">
							<div class="col-md-4">
								<label>页面名称</label>
								<input type="text" name="pagename" class="form-control" placeholder="页面名称" value="@item.PageName">
						</div>
							<div class="col-md-4">
								<label>页面子名称</label>
								<input type="text" name="subtitle" class="form-control" placeholder="页面子名称" value="@item.SubTitle">
						</div>
							<div class="col-md-4">
								<label>页面图标</label>
								<input type="text" name="icon" class="form-control" placeholder="页面图标" value="@item.Icon">
						</div>
						</div>
						<div class="form-group row">
							<div class="col-md-12">
								<label>链接地址</label>
								<div class="input-group">
									<span class="input-group-addon tooltips" data-container="body" data-placement="top" data-original-title="是否显示链接">
										<input type="checkbox" class="chkIsShow" @Html.Raw(item.IsShow ? "checked=\"checked\"" : "")>
									</span>
								<input type="text" name="url" class="form-control" placeholder="链接地址" value="@item.URL">
							</div>
							</div>
						</div>
						<div class="form-group row">
							<div class="col-md-12">
								<label>页面描述</label>
								<textarea class="form-control" name="descr" rows="2" placeholder="页面描述">@item.Descr</textarea>
							</div>
						</div>
						<div class="c-hidden hide">
							<input type="hidden" name="id" value="@item.ID" />
							<input type="hidden" name="pid" value="@item.PID" />
							<input type="hidden" name="sort" value="@item.Sort" />
							<input type="hidden" name="isshow" value="@(item.IsShow ? "true" : "false")" />
						</div>
					</div>
				</div>
				@TreeNode(item.SubMenu)
			</li>
			}
		</ol>
	}
}
<form id="menuForm" action="~/System/UpdateMenu">
	<div class="dd" id="menu-list">
		@TreeNode(MenuList)
	</div>	<div class="mt-30">		<button id="btnSaveMenu" class="btn blue">			<i class="fa fa-save"></i> 保存菜单		</button>		<button id="btnAddMenuItem" class="btn green hide">			<i class="fa fa-plus"></i> 添加新的菜单		</button>	</div></form><div id="context-menu">
	<ul class="dropdown-menu pull-left" role="menu">
		<li>
			<a href="javascript:;" data-event="delete">
			<i class="glyphicon glyphicon-remove"></i> 删除 </a>
		</li>
	</ul>
</div><script type="text/javascript">
    jQuery(document).ready(function () {
        System.initMenuSetting();
    });
</script>